use sqlx::SqlitePool;

use crate::{config::DB_PATH, error::AppErr, utils::UninitCell};

pub mod vote;
pub mod vote_num;


static POOL: UninitCell<SqlitePool> = UninitCell::empty();

pub async fn init() -> Result<(), AppErr> {
    let pool = SqlitePool::connect(DB_PATH).await?;
    unsafe { POOL.init(pool); }
    vote::init().await?;    
    vote_num::init().await?;

    Ok(())
}

#[inline(always)]
pub fn get_pool() -> &'static SqlitePool {
    &POOL
}



